<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <link rel="stylesheet" href="../dist/main.css">
</head>
<body>
<script src="../dist/main.js"></script>
<div id="fogetPass">
   <div class="mainBox">
       <input type="text" placeholder="邮箱" id="mail">
       <div class="inputBox">
           <input type="text" placeholder="邮箱验证码" id="code">
           <button id="getCode">获取验证码</button>
       </div>
       <div class="btns">
           <button class="mui-btn mui-btn-warning" id="bolEmail">验证邮箱</button>
           <button class="mui-btn mui-btn-warning mui-btn-outlined" id="cansel">取消</button>
       </div>

   </div>
</div>
<script>
    $("title").html(mt5Obj.title)
    var bol=true;
    //发送验证码
    mui("body").on('tap','#getCode',function(){
        var mail=$("#mail").val();
        if (emailGe(mail,$("#mail"))){
            return false;
        }else{
            setCode($(this),bol)

            if(bol){
                $.ajax({
                    url: mt5Obj.allUrl+"users/forget/pwd/send/mail",
                    type:"get",
                    data:{
                        toAddress:mail,

                    },
                    success: function(data){
                        if(data.data){
                            mui.alert("发送成功！");

                        }
                    }
                });
            }

        }


    })
    //验证
    mui("body").on('tap','#bolEmail',function(){
        var mail=$("#mail").val();
        var code=$("#code").val();
        if (emailGe(mail,$("#mail"))){
            return false;
        }else if (code==""){
            addWarn( $("#code"),"请输入邮箱验证码！");
        }
        else{
            $.ajax({
                url: mt5Obj.allUrl+"users/mailValidationCodes",
                type:"post",
                data:{
                    mail:mail,
                    mailValidationCode:code,
                },
                success: function(data){
                    if(data.data){
                        sessionStorage.setItem("mail",mail);
                        mui.confirm("身份验证成功，修改新的登录密码。",function(e) {
                            if(e.index == "1") {
                                goUrl("fogetPass2");
                            }
                        })
                    }else if(data.error.code==123411){
                        mui.alert("没有此邮箱，请重新输入")
                    }
                    else{
                        mui.alert("您的验证码填写错误，请重新输入")
                    }
                }
            });

        }

    })
    //取消
    mui("body").on('tap','#cansel',function(){
        goUrl("login")
    })
    removeWarn()
</script>

</body>
</html>


